package com.tywj.panda.customer.usercenter.api

import com.tywj.panda.customer.common.api.CommonApi
import com.tywj.panda.customer.common.cache.CommonCache
import com.tywj.panda.customer.common.manager.AuthorityManager
import com.tywj.panda.customer.common.tool.HttpTool
import com.tywj.lib.net.retrofit.request.PostRequest

/**
 * @desc 用户组件（司机端和用户端共用）网络请求接口
 * @author June Yang
 * @date 2019/12/12
 */
object UserCenterApi {


    //服务订单  http://192.168.2.91:9005/ticket/orderinfo/search/order?uid=x&create_date=x&page_size=1&page_type=10
    // GET /ticket/orderinfo/search/order
    //订单分页查询
    private  var USER_ORDER_LIST = CommonApi.API_TICKET_URL + "ticket/orderinfo/search/order"

    private  var USER_DETAILS = "user/user-detail"

    private  var ORDER_DETAIL = CommonApi.API_TICKET_URL + "ticket/orderinfo/search/order/detail/"

    //修改用户详情  http://192.168.2.91:9001/user/info/update/userDetail
    private  var USER_CENTER_DETAILS = CommonApi.API_USER_URL + "user/info/update/userDetail"

    //保存用户反馈接口，乘客和司机都使用此接口
    private  var FEED_BACK = CommonApi.API_FNC_URL + "feb/save"


    fun getUserDetails(uid: String): PostRequest {
        return HttpTool.post(USER_DETAILS).param("uid", uid)
    }


    /**
     * {
    "avatar": "string",
    "birthday": "string",
    "desc": "string",
    "gender": 0,
    "nick_name": "string",
    "province": "string",
    "province_code": 0,
    "region": "string",
    "region_code": 0,
    "star_signs": "string",
    "uid": "string"
    }
     */
    fun saveUserInfo(avatar: String = "", nickName: String = ""): PostRequest {

        val post = HttpTool.post(USER_CENTER_DETAILS).param("uid", AuthorityManager.uid)

        if (avatar.isNotEmpty()) {
            post.param("avatar", avatar)
        }
        if (nickName.isNotEmpty()) {
            post.param("nick_name", nickName)
        }
        return post

    }

    /**
     * 用户反馈
     */
    fun saveFeedBack(content: String): PostRequest {
        return HttpTool.post(USER_CENTER_DETAILS)
            .param("code", AuthorityManager.uid)
            .param("content", content)
            .param("user_type ", CommonCache.userType)
    }
}